<?php
require_once("init.php");



if(isset($_GET['ref']) && !empty($_GET['ref']))  //check if there is any referrer, then set referrer session.
{
   $_SESSION['ref'] = htmlentities($_GET['ref']); 
}



$template = new Smarty;
$Auth = new Authentication; // $Auth will be used site wide, will be used to check if user is logged in or not


//check if ip is banned to access this site
$isp = mysql_query("SELECT * FROM ipbans WHERE ip = '".getIP()."'");
if(mysql_num_rows($isp))
{
  die( "Your ip is banned to use this website!" );
  return;
}


if($Auth->checkAuth()) // if user is logged in then assign smarty vars ..
{

	$uloggedId = $Auth->getLoggedId();
	$Loggeduser = __User::getById($uloggedId);
	$uid = $uloggedId; 
	if(!$Loggeduser)
	{
	    die("Invalid User");
	}

	$uloggedUser = $Loggeduser->username;
	$template->assign('uloggedUser', $uloggedUser);
	$template->assign('uloggedId', $uloggedId);
	require_once("includes/stats.php");
	
   $myRank = getMyRank($uloggedId);
   $template->assign('myRank', $myRank['rank']);
   $template->assign('myGoal', $myRank['goal']);	
	
	
}else
{
    
	$template->assign('uloggedUser', 0);
	$template->assign('uloggedId', 0);

}



//Site Configuration Variables
$template->assign("SITE_URL", SITE_URL);
$template->assign("SITE_NAME", SITE_NAME);
$template->assign("SITE_KEYWORDS", urldecode(SITE_KEYWORDS));
$template->assign("SITE_DESCRIPTION", urldecode(SITE_DESCRIPTION));
$template->assign("business_paypal_email", BUSINESS_PAYPAL_EMAIL);
$template->assign("paypal_notify_url", urlencode(PAYPAL_NOTIFY_URL));
$template->assign("min_cashout_limit", MIN_CASHOUT_LIMIT);
$template->assign("messages_enabled", ALLOW_MESSAGING);




?>